package A1;

import java.awt.*;
import javax.swing.*;

/**
 * Created by IntelliJ IDEA.
 * User: Sarah
 * Date: 17/08/2011
 * Time: 2:42:01 PM
 * To change this template use File | Settings | File Templates.
 */

public class floorNumbers extends JPanel {

    int numOfFloor;
    JLabel[] floorNum;

    /**
     * Changes the colour of the floor number label if the elevator is on that floor
     */
    public floorNumbers(int numOfFloor) {

        setBackground(Color.lightGray);
        this.numOfFloor = numOfFloor;
        floorNum = new JLabel[numOfFloor + 1];
        for (int i = 1; i <= numOfFloor; i++) {
            floorNum[i] = new JLabel(String.valueOf(i));
            floorNum[i].setForeground(Color.BLACK);
        }

        floorNum[1].setForeground(Color.RED);
        setLayout(new GridLayout(numOfFloor, 1, 0, 0));
        for (int i = numOfFloor; i >= 1; i--) {
            add(floorNum[i]);
			}
		}
}